package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyCommend;
import cn.wolfcode.luowowo.article.mapper.StrategyCommendMapper;
import cn.wolfcode.luowowo.article.query.StrategyCommendQuery;
import cn.wolfcode.luowowo.article.service.IStrategyCommendService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyCommendServiceImpl implements IStrategyCommendService {
    @Autowired
    private StrategyCommendMapper strategyCommendMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return strategyCommendMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(StrategyCommend record) {
        return strategyCommendMapper.insert(record);
    }

    @Override
    public StrategyCommend selectByPrimaryKey(Long id) {
        return strategyCommendMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<StrategyCommend> selectAll() {
        return strategyCommendMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(StrategyCommend record) {
        return strategyCommendMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<StrategyCommend> query(StrategyCommendQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyCommend> list = strategyCommendMapper.QueryForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(StrategyCommend strategyCommend) {
        if (strategyCommend.getId()==null){
            strategyCommendMapper.insert(strategyCommend);
        }else {
            strategyCommendMapper.updateByPrimaryKey(strategyCommend);
        }
    }

    @Override
    public List<StrategyCommend> getHot5() {
        return strategyCommendMapper.getHot5();
    }
}
